Skip to main content

Access Corva Data

Frontend apps run inside an authenticated Corva session. Use the clients exported by @corva/ui/clients; never place an API key, password, or Bearer token in browser code.

import { corvaAPI, corvaDataAPI, socketClient } from '@corva/ui/clients';

Choose the client

ClientUse it for
corvaAPIPlatform resources such as wells, rigs, pads, frac fleets, users, or app metadata
corvaDataAPITime-, depth-, completion-, engineering-, and reference-dataset records
socketClientNew dataset events after the initial Data API request

In most dashboard apps, Corva already supplies the selected drilling or completion assets through useAppCommons. Use their asset_id values for dataset queries rather than searching for the same assets again.

Load recent records

import { corvaDataAPI } from '@corva/ui/clients';

export function fetchLatestWits(assetId: number) {
return corvaDataAPI.get('/api/v1/data/corva/wits/', {
query: JSON.stringify({ asset_id: assetId }),
sort: JSON.stringify({ timestamp: -1 }),
limit: 100,
fields: 'timestamp,asset_id,data.hole_depth,data.bit_depth',
});
}

For completion data, use the appropriate completion dataset and run the request for the wells selected by pad mode.

Request lifecycle

Every data-driven view should define:

  • What it renders before an asset is available.
  • A loading state.
  • A successful empty state.
  • A recoverable error state.
  • Cleanup when the well, pad, or frac fleet changes.
  • How it avoids showing a response for a previously selected asset.

Keep query construction in an api function or a custom hook rather than inside the render body.

Real-time views

A real-time drilling or completion view normally performs an initial corvaDataAPI request, then subscribes with socketClient. Always call the unsubscribe function when the component unmounts or the selected asset changes.

See: